8dd268
@@ -93,6 +93,8 @@
public void compile(final ParseContext pCtx, final List<Task<? extends Serializa
       return;
     }
 
+    optimizeOperatorPlan(pCtx, inputs, outputs);
+
     /*
      * In case of a select, use a fetch task instead of a move task.
      * If the select is from analyze table column rewrite, don't create a fetch task. Instead create
@@ -334,6 +336,13 @@
protected abstract void decideExecMode(List<Task<? extends Serializable>> rootTa
    */
   protected abstract void generateCountersTask(Task<? extends Serializable> rootTask);
 
+  /*
+   * Called at the beginning of the compile phase to have another chance to optimize the operator plan
+   */
+  protected void optimizeOperatorPlan(ParseContext pCtxSet, Set<ReadEntity> inputs, 
+      Set<WriteEntity> outputs) throws SemanticException {
+  }
+
   /*
    * Called after the tasks have been generated to run another round of optimization
    */
